<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:rich="http://richfaces.org/rich"
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:s="http://jboss.org/schema/seam/taglib">

<ui:composition template="../WEB-INF/template/template_2x.xhtml">

  <ui:define name="page_title">#{msgs['jsf.ManageRoles']}</ui:define>
  <ui:define name="right_content">
    <rich:panel>
      <f:facet name="header">#{msgs['jsf.Actions']}</f:facet>
      <s:link styleClass="action_link" action="#{roleAction.createRole}"
        rendered="#{s:hasPermission('seam.account', 'create', null)}"
        value="#{msgs['jsf.CreateRole']}"
        />
    </rich:panel>
  </ui:define>

  <ui:define name="center_content">
    <script type="text/javascript">
      function confirmDelete() {
        return confirm("#{msgs['jsf.AreYouSureYouWishToDeleteThisRoleThisActionCannotBeUndone']}");
      }
    </script>
    <h:form>
      <s:token allowMultiplePosts="true"/>
      <rich:dataTable
        id="threads"
        value="#{roles}"
        var="role"
        cellspacing="0"
        columnClasses="centered,centered,centered"
        styleClass="fullwidth">

        <h:column width="auto">
          <f:facet name="header">#{msgs['jsf.Role']}</f:facet>
          #{role}
        </h:column>
        <h:column width="auto">
          <f:facet name="header">#{msgs['jsf.MemberOf']}</f:facet>
          #{roleSearch.getRoleGroups(role)}
        </h:column>
        <h:column width="auto">
          <f:facet name="header">#{msgs['jsf.Actions']}</f:facet>
          <s:fragment
            rendered="#{s:hasPermission('seam.role', 'update') and accountRoleDAO.findByName(role).roleType.toString() ne 'AUTO'}">
            <h:commandButton value="#{msgs['jsf.Edit']}"
              action="#{roleAction.editRole(roleSearch.selectedRole)}"/>
          </s:fragment>
          <h:commandButton value="#{msgs['jsf.Delete']}"
            action="#{identityManager.deleteRole(roleSearch.selectedRole)}"
            rendered="#{s:hasPermission('seam.role', 'delete') and accountRoleDAO.findByName(role).roleType.toString() ne 'AUTO'}"
            onclick="return confirmDelete()"/>
        </h:column>
      </rich:dataTable>
    </h:form>
  </ui:define>

</ui:composition>
</html>
